package com.ibeeking.found.org.cp.rest.controller.v1.feign;

import com.ibeeking.found.common.entity.EmployeeDTO;
import com.ibeeking.found.common.entity.query.EmployeeFeignQuery;
import com.ibeeking.found.org.api.common.param.EmployeeFeignParam;
import com.ibeeking.found.org.cp.rest.service.IEmployeeService;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName  EmployeeFeignController
 * @Description
 * @Author ibeeking
 * @Date 2021-01-07 12:58
 **/
@RestController
@RequestMapping("/cp/employee/feign/v1")
public class EmployeeFeignController {

    @Resource
    private IEmployeeService employeeServiceImpl;

    /**
     * @param query
     * @return
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询员工")
    @PostMapping(value = "/queryEmployeeList")
    public List<EmployeeDTO> queryEmployeeList(@RequestBody EmployeeFeignQuery query) {
        return employeeServiceImpl.feignQueryEmployeeList(query);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "员工添加或修改")
    @PostMapping(value = "/addOrUpdteEmployee")
    public Boolean addAndUpdteEmployee(@RequestBody @Validated(BaseValidationGroup.Insert.class) EmployeeFeignParam EmployeeParam) {
        return employeeServiceImpl.feignAddorUpdate(EmployeeParam);
    }

}